package com.yj.suncity.activity.shouye;

import com.yj.suncity.R;
import com.yj.suncity.constant.URLCon;
import com.yj.suncity.onekeyshare.ShowShare;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

public class InvitationActivity extends Activity {
	private Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_invitation);
		context = this;
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnHeadBack:
			this.finish();
			break;
		case R.id.lay_rela_1_1:// 微信好友
			showShare("Wechat");
			break;
		case R.id.lay_rela_1_2:// 微信朋友圈
			showShare("WechatMoments");
			break;
		case R.id.lay_rela_1_3:// 新浪微博
			showShare("SinaWeibo");
			break;
		case R.id.lay_rela_2_1:// QQ好友
			showShare("QQ");
			break;
		case R.id.lay_rela_2_2:// 短信
			sendSMS();
			break;
		case R.id.lay_rela_2_3:// 邮件
         sendMail();
			break;
		}
	}

	private void showShare(String platform) {
		ShowShare show = new ShowShare(context, platform, null);
		show.showShare("分享赚金币", "分享就赚钱，你也赶快加入",
				URLCon.HOST + "/web/index.html", "");
	}
	
    private   void  sendMail(){  
        Intent email =  new  Intent(android.content.Intent.ACTION_SEND);  
        email.setType( "plain/text" );  
        String  emailSubject =  "分享就赚钱" ;  
         //设置邮件默认地址   
        // email.putExtra(android.content.Intent.EXTRA_EMAIL, emailReciver);   
         //设置邮件默认标题   
        email.putExtra(android.content.Intent.EXTRA_SUBJECT, emailSubject);  
         //设置要默认发送的内容   
        email.putExtra(android.content.Intent.EXTRA_TEXT, "分享就赚钱，你也赶快加入");  
         //调用系统的邮件系统   
        startActivityForResult(Intent.createChooser(email, URLCon.HOST + "/web/index.html" ), 1001 );  
   }  
    
    //发短信   
    private   void  sendSMS(){  
   Uri smsToUri = Uri.parse( "smsto:" );  
   Intent sendIntent =  new  Intent(Intent.ACTION_VIEW, smsToUri);  
    //sendIntent.putExtra("address", "123456"); // 电话号码，这行去掉的话，默认就没有电话   
   sendIntent.putExtra( "sms_body" ,  "分享就赚钱，你也赶快加入"+URLCon.HOST + "/web/index.html" );  
   sendIntent.setType( "vnd.android-dir/mms-sms" );  
   startActivityForResult(sendIntent, 1002 );  
   }  

}
